***New figures conjoint chapter, compare MM and AMCE	
		
		
		

***Fig.7.6a

set scheme plotplain

use amce_mm_us.dta, clear //US
				
drop if statistic=="AMCE"
				
rename lower yl
rename upper yu
rename estimate ate 
gen tg=0
replace tg=1 if level=="Limited power"
replace tg=2 if level=="Some power"
replace tg=3 if level=="Extensive power"
gen inter=0
replace inter=1 if by=="intcoop: a bad thing"
replace inter=2 if by=="intcoop: neither good nor bad"
replace inter=3 if by=="intcoop: a good thing"

*gen statistic=0
*replace statistic=1 in 4/6
*label define stat 0 "Difference in ACME" 1 "Difference in MM"
 			
local varname ate
local group1 inter
local group2 tg   
sort `group1' `group2'
 
gen x = _n  
ed id by x tg inter
replace x = _n + 1 if _n >= 4
replace x = _n + 2 if _n >= 7

separate ate, by(tg)
separate yu, by(tg)
separate yl, by(tg)
		
twoway (scatter ate1 x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu1 yl1 x, lcolor(black))  ///
       (scatter ate2 x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu2 yl2 x, lcolor(black) )  ///
       (scatter ate3 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu3 yl3 x, lcolor(black) )  ///
, scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("") ///
	   ytitle(Marginal Means, size(3)) yscale(r(0.35(.15)0.6)) ///
	   text(0.34 1.5 "a bad thing", place(e) size(2.5)) ///
	   text(0.34 5 "neither good nor bad", place(e) size(2.5)) ///
	   text(0.34 9 "a good thing", place(e) size(2.5)) ///
	   legend(order(1 "Limited power" 3 "Some power" 5 "Extensive power") position(1) row(1) ring(0)) ///
	   graphregion(color(white)) ylab(, labsize(2.5) nogrid) 
	   
	   
	   
***Fig.7.6b

set scheme plotplain

use amce_mm_us.dta, clear //US
				
drop if statistic=="MMs"
				
rename lower yl
rename upper yu
rename estimate ate 
gen tg=0
replace tg=1 if level=="Limited power"
replace tg=2 if level=="Some power"
replace tg=3 if level=="Extensive power"
gen inter=0
replace inter=1 if by=="intcoop: a bad thing"
replace inter=2 if by=="intcoop: neither good nor bad"
replace inter=3 if by=="intcoop: a good thing"

*gen statistic=0
*replace statistic=1 in 4/6
*label define stat 0 "Difference in ACME" 1 "Difference in MM"
 			
local varname ate
local group1 inter
local group2 tg   
sort `group1' `group2'
 
gen x = _n  
ed id by x tg inter
replace x = _n + 1 if _n >= 4
replace x = _n + 2 if _n >= 7

separate ate, by(tg)
separate yu, by(tg)
separate yl, by(tg)
		
twoway (scatter ate1 x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu1 yl1 x, lcolor(black))  ///
       (scatter ate2 x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu2 yl2 x, lcolor(black) )  ///
       (scatter ate3 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu3 yl3 x, lcolor(black) )  ///
, scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("") ///
	   ytitle(Average Marginal Component Effects, size(3)) yscale(r(-0.25(.25)0.25)) ///
	   text(-0.27 1.5 "a bad thing", place(e) size(2.5)) ///
	   text(-0.27 5 "neither good nor bad", place(e) size(2.5)) ///
	   text(-0.27 9 "a good thing", place(e) size(2.5)) ///
	   legend(order(1 "Limited power" 3 "Some power" 5 "Extensive power") position(1) row(1) ring(0)) ///
	   graphregion(color(white)) ylab(, labsize(2.5) nogrid)   ///
yline(0, lcolor(black) lpattern(dash)) 
   
	   
		
		
		
		
		

***Fig.7.8a

set scheme plotplain

use "/Users/mariadellmuth/Dropbox/Papers/Sociallegitimacy/Legitimacy Book/Analysis/ch7_socialpurpose-conjoint/conjointmm/amce_mm_us_purpose.dta", clear
				
drop if statistic=="AMCE"
				
rename lower yl
rename upper yu
rename estimate ate 
gen tg=0
replace tg=1 if level=="ensure peace and security"
replace tg=2 if level=="reduce poverty"
replace tg=3 if level=="protect human rights"
replace tg=4 if level=="promote free trade"
replace tg=5 if level=="combat climate change"
replace tg=6 if level=="promote public health"
gen inter=0
replace inter=1 if by=="twolargestparties: Democrats"
replace inter=2 if by=="twolargestparties: Republicans"
replace inter=3 if by=="twolargestparties: Independents"

*gen statistic=0
*replace statistic=1 in 4/6
*label define stat 0 "Difference in ACME" 1 "Difference in MM"
 			
local varname ate
local group1 inter
local group2 tg   
sort `group1' `group2'
 
gen x = _n  
ed id by x tg inter
replace x = _n + 2 if _n >= 7
replace x = _n + 4 if _n >= 13


separate ate, by(tg)
separate yu, by(tg)
separate yl, by(tg)
		
twoway (scatter ate1 x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu1 yl1 x, lcolor(black))  ///
       (scatter ate2 x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu2 yl2 x, lcolor(black) )  ///
       (scatter ate3 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu3 yl3 x, lcolor(black) )  ///
       (scatter ate4 x , msymbol(C) msize(medium) mcolor(black)) ///
       (rcap yu4 yl4 x, lcolor(black) )  ///
       (scatter ate5 x , msymbol(D) msize(medium) mcolor(black)) ///
       (rcap yu5 yl5 x, lcolor(black) )  ///
       (scatter ate6 x , msymbol(oh) msize(medium) mcolor(black)) ///
       (rcap yu6 yl6 x, lcolor(black) )  ///
, scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("") ///
	   ytitle(Marginal Means, size(3)) yscale(r(0.35(.2)0.8)) ///
	   text(0.34 1.5 "Democrats", place(e) size(2.5)) ///
	   text(0.34 10 "Republicans", place(e) size(2.5)) ///
	   text(0.34 16 "Independents", place(e) size(2.5)) ///
	   legend(order(1 "Peace and security" 3 "Combat poverty" 5 "Human rights" 7 "Free trade" 9 "Climate change" 11 "Public health") position(1) row(2) ring(0)) ///
	   graphregion(color(white)) ylab(, labsize(2.5) nogrid angle(horizontal)) 
	   
	   
	   
***Fig.7.8b

use "/Users/mariadellmuth/Dropbox/Papers/Sociallegitimacy/Legitimacy Book/Analysis/ch7_socialpurpose-conjoint/conjointmm/amce_mm_us_purpose.dta", clear

			
drop if statistic=="MMs"
				
rename lower yl
rename upper yu
rename estimate ate 
gen tg=0
replace tg=1 if level=="ensure peace and security"
replace tg=2 if level=="reduce poverty"
replace tg=3 if level=="protect human rights"
replace tg=4 if level=="promote free trade"
replace tg=5 if level=="combat climate change"
replace tg=6 if level=="promote public health"
gen inter=0
replace inter=1 if by=="twolargestparties: Democrats"
replace inter=2 if by=="twolargestparties: Republicans"
replace inter=3 if by=="twolargestparties: Independents"
			
local varname ate
local group1 inter
local group2 tg   
sort `group1' `group2'
 
gen x = _n  
ed id by x tg inter
replace x = _n + 2 if _n >= 7
replace x = _n + 4 if _n >= 13

separate ate, by(tg)
separate yu, by(tg)
separate yl, by(tg)
		
twoway (scatter ate1 x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu1 yl1 x, lcolor(black))  ///
       (scatter ate2 x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu2 yl2 x, lcolor(black) )  ///
       (scatter ate3 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu3 yl3 x, lcolor(black) )  ///
	   (scatter ate4 x , msymbol(C) msize(medium) mcolor(black)) ///
       (rcap yu4 yl4 x, lcolor(black) )  ///
       (scatter ate5 x , msymbol(D) msize(medium) mcolor(black)) ///
       (rcap yu5 yl5 x, lcolor(black) )  ///
       (scatter ate6 x , msymbol(oh) msize(medium) mcolor(black)) ///
       (rcap yu6 yl6 x, lcolor(black) )  ///
, scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("") ///
	   ytitle(Average Marginal Component Effects, size(3)) yscale(r(-0.3(.1)0.2)) ///
	   text(-0.33 2 "Democrats", place(e) size(2.5)) ///
	   text(-0.33 11 "Republicans", place(e) size(2.5)) ///
	   text(-0.33 17 "Independents", place(e) size(2.5)) ///
	   legend(order(1 "Peace and security" 3 "Combat poverty" 5 "Human rights" 7 "Free trade" 9 "Climate change" 11 "Public health") position(1) row(2) ring(0)) ///
	   graphregion(color(white)) ylab(, labsize(2.5) nogrid angle(horizontal))   ///
yline(0, lcolor(black) lpattern(dash)) 
  

	   
